package divinity.fx.vfx
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventPhase;
	
	import divinity.animation.SpeedController;
	import divinity.basic.*;
	public class AnimatedFX extends DivinityObject
	{
		private var _world:DivinityWorld;
		private var _img:MovieClip;
		private var _cont:SpeedController;
		public function AnimatedFX(wld:DivinityWorld,mcx:Number,mcy:Number,mc:MovieClip=null)
		{
			super();
			_world=wld;
			_cont=new SpeedController(wld);
			x=mcx;
			y=mcy;
			if(mc!=null)
			{
				animation=mc;
			}
		}
		public function play(label:String,timeframe:int)
		{
			trace("playing");
			_cont.sequence(label,timeframe,1);
			_cont.addEventListener(label,done);
		}
		public function set animation(mc:MovieClip)
		{
			_img=mc;
			_cont.img=_img;
			addChild(_img);
		}
		private function done(e:Event)
		{
			trace("FX done");
			if(parent!=null)
			{
				trace("removing",this);
				parent.removeChild(this);
			}
			
			
		}
	}
}